<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>改变this指向</title>
</head>
<body>
    <script>
        //call apply bind
        var obj = {
            name: 'obj',
            test: function(a, b, c) {
                console.log('obj调用', this.name, a, b, c);
            }
        };
        obj.test(); // obj
        var obj1 = {
            name: 'obj1',
            test: function() {
                console.log('obj1调用', this.name);
            }
        };
        obj1.test(); // obj1

        obj.test.call(obj1, 1 , 2, 3); // obj1
        obj.test.apply(obj1, [1, 2, 3]); // obj1
        obj.test.bind(obj1)(1, 2, 3); // obj1
    </script>
</body>
</html>